<template>
  <div class="computed">
    hello computed
    <input type="text" v-model.trim="question" />
    {{answer}}
  </div>
</template>

<script>
  let delayer = (action, delay = 600) => {
    let timer = -1;
    return nv => {
      clearTimeout(timer);
      timer = setTimeout(() => {
        action(nv);
      }, delay);
    };
  }
  export default {
    name: "Computed",
    data() {
      return {
        question:10,
        answer:'init'
      }
    },
    watch:{
      question: delayer(nv => {
        console.log(this.answer)
        this.answer = nv;
        console.log(this.answer);
      }),
    }
  }
</script>

<style scoped>

</style>
